/*
 * PrinterDelegate.h  0.4.0 / Dec 04, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef PRINTERDELEGATE_H
#define PRINTERDELEGATE_H

#include "Cute4jSwing.h"

// PrinterDelegate Class. ------------------------------------------------------

/*!
 * \brief Printer Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT PrinterDelegate : public QObject
{
  Q_OBJECT
protected:
  PrinterDelegate(JNIEnv *env, jobject obj);
  virtual ~PrinterDelegate();
public slots: // native calls
  void destroy(JNIEnv *env);
  void pageDialog(JNIEnv *env);
  jboolean printerDialog(JNIEnv *env);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj);
public:
  inline QPrinter *qPrinter() const;
public:
  static QPrinter *toQPrinter(JNIEnv *env, jobject printer);
private:
  jweak m_wobjref;
  QPrinter *m_printer;
private:
  static jfieldID sm_delegateFID;
  static jmethodID sm_createMID;
};

// PrinterDelegate :: Inline Member Function. ----------------------------------

/*!
 * \brief Returns QPrinter adaptee.
 *
 * \return QPrinter adaptee
 */
inline QPrinter *PrinterDelegate::qPrinter() const
{
  return m_printer;
}

// Macro Definitions. ----------------------------------------------------------

#define PRINTER_CAST(delegate) (reinterpret_cast<PrinterDelegate *>(delegate))
#define PRINTER_DELEGATE PRINTER_CAST(delegate)

#endif // PRINTERDELEGATE_H
